home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue29 / system / LibExp / LibTestForm.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1997-11-27  |  4.7 KB  |  178 lines

  1. unit LibTestForm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, LibIntf,
  7.   StdCtrls, ExtCtrls, Tabs, Menus;
  8.  
  9. type
  10.   TLibExTest = class(TForm)
  11.     TabSet1: TTabSet;
  12.     Notebook1: TNotebook;
  13.     GroupBox1: TGroupBox;
  14.     Label1: TLabel;
  15.     BaseReg: TEdit;
  16.     GroupBox2: TGroupBox;
  17.     Label6: TLabel;
  18.     Label3: TLabel;
  19.     DisplayGrid: TCheckBox;
  20.     SnapToGrid: TCheckBox;
  21.     ShowComponentCaptions: TCheckBox;
  22.     GridSizeX: TEdit;
  23.     GridSizeY: TEdit;
  24.     GroupBox5: TGroupBox;
  25.     ComboBox1: TComboBox;
  26.     Image2: TImage;
  27.     cbLockState: TCheckBox;
  28.     Label5: TLabel;
  29.     PathAndBaseName: TLabel;
  30.     Label7: TLabel;
  31.     AppHandle: TLabel;
  32.     Label8: TLabel;
  33.     IDETime: TLabel;
  34.     Label9: TLabel;
  35.     WinSize: TLabel;
  36.     Label4: TLabel;
  37.     Image1: TImage;
  38.     GroupBox4: TGroupBox;
  39.     Label2: TLabel;
  40.     HelpClassName: TEdit;
  41.     ClassHelpOK: TButton;
  42.     GroupBox3: TGroupBox;
  43.     ComboBox2: TComboBox;
  44.     Label10: TLabel;
  45.     Button1: TButton;
  46.     procedure FormCreate(Sender: TObject);
  47.     procedure HelpClassNameChange(Sender: TObject);
  48.     procedure ClassHelpOKClick(Sender: TObject);
  49.     procedure FormPaint(Sender: TObject);
  50.     procedure TabSet1Change(Sender: TObject; NewTab: Integer;
  51.       var AllowChange: Boolean);
  52.     procedure ComboBox1Change(Sender: TObject);
  53.     procedure Button1Click(Sender: TObject);
  54.   private
  55.     { Private declarations }
  56.   public
  57.     { Public declarations }
  58.   end;
  59.  
  60. implementation
  61.  
  62. {$R *.DFM}
  63.  
  64. procedure TLibExTest.FormCreate(Sender: TObject);
  65. var
  66.     r: TRect;
  67.     Opts: TDesignerOptions;
  68. begin
  69.     TabSet1.Tabs := NoteBook1.Pages;
  70.     
  71.     with DelphiIDE do begin
  72.         BaseReg.Text := GetBaseRegKey;
  73.         GetDesignerOptions (Opts);
  74.         DisplayGrid.Checked := Opts.DisplayGrid;
  75.         SnapToGrid.Checked := Opts.SnapToGrid;
  76.         ShowComponentCaptions.Checked := Opts.ShowComponentCaptions;
  77.         GridSizeX.Text := IntToStr (Opts.GridSizeX);
  78.         GridSizeY.Text := IntToStr (Opts.GridSizeY);
  79.         cbLockState.Checked := LockState;
  80.         PathAndBaseName.Caption := GetPathAndBaseExeName;
  81.         AppHandle.Caption := '$' + IntToHex (GetAppHandle, 8);
  82.         IDETime.Caption := '$' + IntToHex (GetCurTime, 8);
  83.         r := GetMainWindowSize;
  84.         WinSize.Caption := Format ('(%d,%d)-(%d,%d)', [r.Left, r.Top, r.Right, r.Bottom]);
  85.         ComboBox1.ItemIndex := 0;
  86.         ComboBox2.ItemIndex := 0;
  87.         ComboBox1Change (Self);
  88.     end;
  89. end;
  90.  
  91. procedure TLibExTest.HelpClassNameChange(Sender: TObject);
  92. begin
  93.     ClassHelpOK.Enabled := HelpClassName.Text <> '';
  94. end;
  95.  
  96. procedure TLibExTest.ClassHelpOKClick(Sender: TObject);
  97. begin
  98.     DelphiIDE.ShowClassHelp (HelpClassName.Text);
  99. end;
  100.  
  101. procedure TLibExTest.FormPaint(Sender: TObject);
  102. var
  103.     Item: TIPaletteItem;
  104. begin
  105.     with DelphiIDE do
  106.         if GetToolSelected then begin
  107.             Label4.Visible := True;
  108.             Image1.Visible := True;
  109.             Item := GetCurCompClass;
  110.             try
  111.                 Item.Paint (Image1.Canvas, 0, 0);
  112.             finally
  113.                 Item.Free;
  114.             end;
  115.         end
  116.         else begin
  117.             Label4.Visible := False;
  118.             Image1.Visible := False;
  119.         end;
  120. end;
  121.  
  122. procedure TLibExTest.TabSet1Change (Sender: TObject; NewTab: Integer;
  123.                                     var AllowChange: Boolean);
  124. begin
  125.     NoteBook1.PageIndex := NewTab;
  126. end;
  127.  
  128. procedure TLibExTest.ComboBox1Change(Sender: TObject);
  129. var
  130.     Item: TIPaletteItem;
  131.     Cls: TComponentClass;
  132. begin
  133.     with DelphiIDE do begin
  134.         case ComboBox1.ItemIndex of
  135.             0:      Cls := TMainMenu;
  136.             1:      Cls := TPopupMenu;
  137.             2:      Cls := TLabel;
  138.             3:      Cls := TEdit;
  139.             4:      Cls := TMemo;
  140.             5:      Cls := TButton;
  141.             6:      Cls := TCheckBox;
  142.             7:      Cls := TRadioButton;
  143.             8:      Cls := TListBox;
  144.             9:      Cls := TComboBox;
  145.             10:     Cls := TScrollBar;
  146.             11:     Cls := TGroupBox;
  147.             12:     Cls := TRadioGroup;
  148.             13:     Cls := TPanel;
  149.             else    Cls := Nil;
  150.         end;
  151.  
  152.         if Cls = Nil then Image2.Visible := False else begin
  153.             Item := GetPaletteItem (Cls);
  154.             try
  155.                 Item.Paint (Image2.Canvas, 0, 0);
  156.             finally
  157.                 Item.Free;
  158.             end;
  159.             Image2.Visible := True;
  160.             Image2.Invalidate;
  161.         end;
  162.     end;
  163. end;
  164.  
  165. procedure TLibExTest.Button1Click (Sender: TObject);
  166. begin
  167.     { This will do nothing if there's no active form }
  168.     DelphiIDE.ExecDesignDialog (TDesignDialog (ComboBox2.ItemIndex));
  169. end;
  170.  
  171. end.
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.